import { defineUserConfig } from "vuepress";
import theme from "./theme.js";
import { searchProPlugin } from "vuepress-plugin-search-pro";
import { photoSwipePlugin } from "vuepress-plugin-photo-swipe";

export default defineUserConfig({
  lang: "zh-CN",
  title: "集思栈",
  description: "奋发有为，时不待我",
  head: [['link', { rel: 'icon', href: '/logo.ico' }],[
    'script', {}, `
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?f86714f7e69ade978ec5842bcd4dd18f";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
    `
  ]],

  theme,
  shouldPrefetch: false,
  plugins: [
    searchProPlugin({
      // 索引全部内容
      indexContent: true,
      locales: {
        "/zh/": {
          placeholder: "搜索",
        },
      },
      // 为分类和标签添加索引
      customFields: [{
        name: "author",
        getter: (page) => page.frontmatter.author,
        formatter: "作者：$content",
      },
        {
          getter: (page) => page.frontmatter.category,
          formatter: "分类：$content",
        },
        {
          getter: (page) => page.frontmatter.tag,
          formatter: "标签：$content",
        }, 
        {
          name: "updateTime",
          getter: (page) => page.data.git?.updateTime.toLocaleString(),
          formatter: {
            // "/": "Update time: $content",
            "/zh/": "更新时间：$content",
          },
        }
      ],
    }),
  ],
  // Enable it with pwa
  // shouldPrefetch: false,
});
